package fr.babostesting.unit.components.lists 
{
	import flash.geom.Matrix;
	import fr.babos.graphic.components.base.BorderComponent;
	import fr.babos.graphic.components.base.ResizableComponent;
	import fr.babos.graphic.components.controls.text.Label;
	
	/**
	 * ...
	 * @author ZoulouX
	 */
	public class FreeListElement extends ResizableComponent 
	{
		protected var _hasContent:Boolean;
		
		public function FreeListElement (pHasContent:Boolean, pIndex:int = 0)
		{
			(new BorderComponent(0x666666, 1)).place(0, 0, 0, 0).into(this);
			
			//opaqueBackground = true;
			
			_hasContent = pHasContent;
			
			if (pHasContent)
			{
				(new Label(false)).text(pIndex + " - " + Math.random()).interactive(false).place(10, 10, NaN, 10).into(this);
			}
			
			cab(true);
		}
		
		override protected function resized ():void
		{
			if (_localWidth > 0 && _localHeight > 0)
			{
				graphics.clear();
				
				if (_hasContent)
				{
					graphics.beginFill(0xFFFFFF * Math.random());
				}
				else
				{
					graphics.beginFill(0xFFFFFF);
				}
				
				graphics.drawRect(0, 0, _localWidth, _localHeight);
				graphics.endFill();
			}
		}
	}
}